/*
 * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @Date: 2025-07-13 15:11:08
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2025-07-15 15:20:18
 * @FilePath: /NetProjectVideo/source_code/aod.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include"util.hpp"
#include"data_management.hpp"
#include"server.hpp"

void FileTest()
{
    aod::FileUtil("./wwwroot").CreateDirectory();
    aod::FileUtil("./wwwroot/index.html").SetConnect("hello");

    std::string body;// 读取到body里面
    aod::FileUtil("./wwwroot/index.html").GetConnect(&body);
    
    std::cout<<body<<std::endl;
    std::cout<<aod::FileUtil("./wwwroot/index.html").Size()<<std::endl;
}


void JsonTest()
{
    Json::Value val;
    val["姓名"]="小明";
    val["性别"]="男";
    val["年龄"]=18;
    val["成绩"].append(66);
    val["成绩"].append(77);
    val["成绩"].append(88);
    

    std::string str;
    aod::JsonUtil::Serialize(val,&str);
    
    std::cout<<str<<std::endl;

    Json::Value stu;
    aod::JsonUtil::Unserialize(str,&stu);
    std::cout<<stu["姓名"].asString()<<std::endl;
    std::cout<<stu["性别"].asString()<<std::endl;
    std::cout<<stu["年龄"].asString()<<std::endl;
    for(auto &a:stu["成绩"])
    {
        std::cout<<a.asFloat()<<std::endl;
    }
}

void DataTest()
{
    aod::TableVideo tb_vi;// 创建“数据库管理”对象！
    Json::Value vi;
    vi["name"]="你行你上";
    vi["info"]="2025年 姜文导演新作：你要去看吗？";
    vi["video"]="/video/put_up_or_shut_up.mp4";
    vi["image"]="/image/put_up_or_shut_up.jpg";
    
    //tb_vi.Insert(vi);
    //tb_vi.Update(2,&vi);
    //Json::Value video;
    //tb_vi.Selectone(2,&video);

}
void ServerTest()
{
    aod::Server server(9090);
    server.Module();
}

int main()
{
    //FileTest();
    //JsonTest();
    //DataTest();

    ServerTest();
    return 0;
}
